//
//  SYLeaveSelView.m
//  ChatDemo-UI2.0
//
//  Created by zz on 16/8/16.
//  Copyright © 2016年 zz. All rights reserved.
//  请假时候选择view

#import "SYLeaveSelView.h"

@interface SYLeaveSelView()<UITextFieldDelegate>

@end


@implementation SYLeaveSelView

-(instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        
        _leftLabel = [[UILabel alloc] initWithFrame:CGRectMake(12, 12, 80, 15)];
        _leftLabel.font = [UIFont systemFontOfSize:15];
        _leftLabel.textColor = RGBCOLOR(59, 59, 59);
        [self addSubview:_leftLabel];
        
        _selBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _selBtn.frame = CGRectMake(frame.size.width - 150, 0, 150, frame.size.height);
        [_selBtn setTitle:@"请选择" forState:UIControlStateNormal];
        [_selBtn addTarget:self action:@selector(selectAction:) forControlEvents:UIControlEventTouchUpInside];
        [_selBtn setTitleColor:RGBCOLOR(151, 151, 151) forState:UIControlStateNormal];
        //[self addSubview:_selBtn];
        
        _textField = [[UITextField alloc] initWithFrame:CGRectMake(frame.size.width - 150-12, 0, 150, frame.size.height)];
        _textField.placeholder = @"请选择";
        _textField.textAlignment = NSTextAlignmentRight;
        _textField.delegate = self;
        _textField.font=[UIFont systemFontOfSize:15];
        [self addSubview:_textField];
        
        _topLineView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, 0.5)];
        _topLineView.backgroundColor = RGBCOLOR(199,199,204);
        [self addSubview:_topLineView];
        
        _bottomLineView = [[UIView alloc] initWithFrame:CGRectMake(0, frame.size.height - 0.5, frame.size.width, 0.5)];
        _bottomLineView.backgroundColor =RGBCOLOR(199,199,204);
        [self addSubview:_bottomLineView];
        
        self.userInteractionEnabled = YES;
        self.backgroundColor = [UIColor whiteColor];
    }
    
    return self;
}

-(void)selectAction:(UIButton *)sender{
    
    if (self.delegate && [_delegate respondsToSelector:@selector(selActionWithSender:)]) {
        
        [_delegate selActionWithSender:sender];
        
    }
}

-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
    
    if (self.delegate && [_delegate respondsToSelector:@selector(selActionWithSender:)]) {
        
       return [_delegate selActionWithSender:textField];
    }
    
    return YES;
}



/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
